Add date subheaders to the RS comment list - #23139
Conversation
Interleave date-group headers into the rs comment list, matching the legacy list. A new withDateHeaders() groups consecutive comments by their existing relativeDate label (the same javaDateToTimeSpan value legacy groups by) and inserts a header row on each change; the LazyColumn renders headers and comments as distinct row types.
Generated by 🚫 Danger |
|
|
|
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #23139 +/- ##
=======================================
Coverage 37.83% 37.83%
=======================================
Files 2344 2345 +1
Lines 127482 127515 +33
Branches 17703 17711 +8
=======================================
+ Hits 48229 48244 +15
- Misses 75296 75313 +17
- Partials 3957 3958 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Key each date header by its label instead of the group's first comment id, so a header stays stable (no remove+add re-animation) when a newer comment is prepended into an existing date group. Labels are unique per contiguous group given the date sort. Drops the now-unneeded keyId field. - Uppercase the header label with the default locale, matching the legacy subheader's locale-aware textAllCaps (Kotlin's no-arg uppercase() is Locale.ROOT and mis-cases e.g. Turkish month names).
This comment was marked as resolved.
This comment was marked as resolved.
Reading Locale.getDefault() in a composable trips lint's NonObservableLocale (the header wouldn't recompose on a locale change). Read the locale from LocalConfiguration via ConfigurationCompat instead, matching the existing stats-card pattern, keeping the locale-aware uppercase.
|
It looks like the new logic could end up in a possible crash. So, I would take a look:
|
The header LazyColumn key relied on the invariant that date-sorted comments make each label one contiguous group. If the list ever arrived out of date order a label could repeat non-contiguously, producing a duplicate key -> LazyColumn IllegalArgumentException (a crash, where the legacy list only showed a redundant header). withDateHeaders now mints a guaranteed-unique key per header (still just the label in the normal case, disambiguated only on a non-contiguous repeat), so correctness no longer depends on the sort order.
Once again I'm surprised that my Claude review didn't uncover this potential problem. Fixed in eeaf9d7. |
I'm in a mode where I always expect new potential issues when someone else reviews my PRs, using the exact ask to Claude I did like 2 or 3 times before opening it. 😅 |


What
Adds date-group subheaders to the RS comment list matching the legacy comments list.
Testing